how to find repeating elements in an array